package com.wangzhy.financial.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.wangzhy.financial.domain.DeptJxmb;
import com.wangzhy.financial.service.IDeptJxmbService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 绩效目标Controller
 *
 * @author wangzhy
 * @date 2021-11-08
 */
@RestController
@RequestMapping("/financial/jxmb")
@Api(tags = "绩效目标Controller")
public class DeptJxmbController extends BaseController
{
    @Autowired
    private IDeptJxmbService deptJxmbService;

    /**
     * 查询绩效目标列表
     */
    @ApiOperation("查询绩效目标列表")
    @PreAuthorize("@ss.hasPermi('system:jxmb:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeptJxmb deptJxmb)
    {
        startPage();
        List<DeptJxmb> list = deptJxmbService.selectDeptJxmbList(deptJxmb);
        return getDataTable(list);
    }

    /**
     * 导出绩效目标列表
     */
    @ApiOperation("导出绩效目标列表")
    @PreAuthorize("@ss.hasPermi('system:jxmb:export')")
    @Log(title = "绩效目标", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DeptJxmb deptJxmb)
    {
        List<DeptJxmb> list = deptJxmbService.selectDeptJxmbList(deptJxmb);
        ExcelUtil<DeptJxmb> util = new ExcelUtil<DeptJxmb>(DeptJxmb.class);
        return util.exportExcel(list, "jxmb");
    }

    /**
     * 获取绩效目标详细信息
     */
    @ApiOperation("获取绩效目标详细信息")
    @PreAuthorize("@ss.hasPermi('system:jxmb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(deptJxmbService.selectDeptJxmbById(id));
    }

    /**
     * 新增绩效目标
     */
    @ApiOperation("新增绩效目标")
    @PreAuthorize("@ss.hasPermi('system:jxmb:add')")
    @Log(title = "绩效目标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeptJxmb deptJxmb)
    {
        return toAjax(deptJxmbService.insertDeptJxmb(deptJxmb));
    }

    /**
     * 修改绩效目标
     */
    @ApiOperation("修改绩效目标")
    @PreAuthorize("@ss.hasPermi('system:jxmb:edit')")
    @Log(title = "绩效目标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeptJxmb deptJxmb)
    {
        return toAjax(deptJxmbService.updateDeptJxmb(deptJxmb));
    }

    /**
     * 删除绩效目标
     */
    @ApiOperation("删除绩效目标")
    @PreAuthorize("@ss.hasPermi('system:jxmb:remove')")
    @Log(title = "绩效目标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(deptJxmbService.deleteDeptJxmbByIds(ids));
    }
}
